package design.p17_chainOfResponsibility;

/**
 * @ClassName: Java
 * @description:
 * @author: zxf
 * @create: 2021-06-19 22:33
 **/
public class MyHandler extends AbstractHandler implements Handler{

    private String name;

    public MyHandler(String name){
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void operator() {
        System.out.println(name+"deal~~~");
        if (getHandler() != null){
            getHandler().operator();
        }
    }

    public static void main(String[] args) {
        MyHandler h1 = new MyHandler("h1");
        MyHandler h2 = new MyHandler("h2");
        MyHandler h3 = new MyHandler("h3");
        h1.setHandler(h2);
        h2.setHandler(h3);
        h1.operator();
    }
}

